package singleton;
//双检测机制,实现单例
public class DoubleCheck {
	private volatile static DoubleCheck doubleCheck;
	private DoubleCheck(){
		
	}
	public static DoubleCheck getInstance(){
		if(doubleCheck!=null){

		}else{
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				
				e.printStackTrace();
			}
			synchronized (DoubleCheck.class) {
				if(doubleCheck==null){
					System.out.println("goood");
					return doubleCheck=new DoubleCheck();
				}
			}
		}
		return doubleCheck;
	}
}
